Field of the Invention
The present invention relates to a communication apparatus, a control method of the communication apparatus, and a program.
Description of the Related Art
In recent years, wireless local area network (LAN) has been commonly provided for terminal apparatuses such as mobile phones, digital cameras, and printers in addition to personal computers (PCs). For example, Japanese Patent Application Laid-Open No. 2011-35768 discloses a method for easily sharing an image by employing a camera with a wireless LAN function.
An infrastructure mode in which terminals beneath a base station communicate with each other via the base station, and an ad hoc mode in which the terminals directly communicate with each other are provided as the connection modes of the wireless LAN apparatuses.
Although the base station is required for communicating in the infrastructure mode, there is provided a technique which enables the terminals to communicate with each other in the infrastructure mode even if the base station is not present in the communication environment. For the technique, the terminal includes a base station function so that the terminal can also operate as a base station.
Wi-Fi Alliance, that is, an industry association of the wireless LAN, standardizes Wi-Fi Direct which defines a specification for realizing direct communication between terminals by using a terminal that includes a base station function. A method for determining an apparatus operating as a base station, a method for setting parameters for the terminals to connect to the apparatus operating as the base station, and a connection method therefor are described in Wi-Fi Direct.
In Wi-Fi Direct, an apparatus that operates as the base station is defined as a group owner (GO), and a terminal apparatus that connects to the GO is defined as a Client. The terminal apparatus exchanges capability information with each other, so as to determine the apparatus that operates as a GO. The apparatus that is determined to be the GO activates a base station function to establish a wireless LAN network. By using Wi-Fi Protected Setup (WPS), each of the Clients executes wireless LAN parameter setting with respect to the wireless LAN network established by the GO in order to connect thereto. With this operation, the GO and the Clients form a wireless LAN network known as a peer-to-peer (P2P) group, so that the GO and the Clients can directly communicate through the wireless LAN in the P2P group.
Further, even before connecting through the wireless LAN network, it is possible to acquire service information of a communication partner apparatus by using a service discovery function specified in Wi-Fi Direct. The information of the service in an upper layer can be included in the service information.
However, in a case where the apparatus finds a communication partner apparatus for a desired service in a wireless layer section and randomly forms a P2P group with that communication partner apparatus, the apparatus may form a useless P2P group. For example, in a case where a connection is directly made through the wireless LAN, the apparatus may receive an instruction for starting a second service while the apparatus is executing a first service within one P2P group. At this time, the apparatus finds a communication partner apparatus through a Service Discovery for the second service, and newly forms another P2P group with that communication partner apparatus.
In such a case, if the communication partner apparatus for the first service is the same as the communication partner apparatus for the second service, the above operation is inefficient since the P2P groups are formed in an overlapping manner. The same can be also said if the communication partner apparatus for the second service is present in the P2P group in which the first service is being executed.